{extend name="template/base" /}
{block name="content"}
<script type="text/javascript" language="JavaScript">
		function getColumn() {
			//alert($("#table_name").val());
			var  eq="{eq name="$data.table_name" value="+oResults[i].name+"}selected{/eq}";
			$.post("{:\\think\\Url::build('/admin/field/getColumn')}",{table_name:$("#table_name").val()},function(data) {
				$("#field_name").empty();
				//alert(data.status);
				if(data.status == "1") {
					var oResults = data.data;
	                for (var i = 0, len = oResults.length; i < len; i++) {
	                    $("<option {eq name='data.field_name'  value='"+oResults[i].name+"'}selected{/eq}    value='"+oResults[i].name+"'>"+oResults[i].name+"</option>").appendTo("#field_name");
	                }
				} else {
					//alert(data.info);
				}
			}, 'json');
		}
		
	</script>
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <input type="hidden" name="id" value="{$data.id ??''}">
		 <input type="hidden" name="operator" value="{$operator ??''}">
            <div class="row cl" style="margin-top:50px">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>数据表：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <select  name="table_name" id="table_name" onChange="getColumn();" class="input-text" datatype="*" nullmsg="请选择表名称">
				<option value="0">请选择表名</option>
				{volist name="table_list" id="vo"}
					<option {eq name="$data.table_name" value="$vo.name"}selected{/eq} value="{$vo.name}">{$vo.name}</option>
				{/volist}
				</select> 
                
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
         <div class="row cl" onload="getColumn();">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>字段：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <select name="field_name" id="field_name" class="input-text" datatype="*" nullmsg="请选择字段" >
                	<option value="0">请选择字段</option>
					{volist name="field_list" id="vo1"}
					<option {eq name="$data.field_name" value="$vo1.name"}selected{/eq} value="{$vo1.name}">{$vo1.name}</option>
					{/volist}
                </select>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>数据值：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="数据值" name="field_value" value="{$data.field_value ?? ''}"  datatype="*" nullmsg="请填写数据值">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>含义：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="含义" name="field_mean" value="{$data.field_mean ?? ''}"  datatype="*" nullmsg="请填写含义">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">状态：</label>
            <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                  <div class="radio-box">
                    <input type="radio" name="status" value="1" {eq name="$data.status" value="1"}checked{/eq} />
                    <label for="status-1">启用</label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="status" value="0" {eq name="$data.status" value="0"}checked{/eq} />
                    <label for="status-0">禁用</label>
                </div>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">备注：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="备注" name="remark" value="{$data.remark ?? ''}" >
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>
    $(function () {
        $("[name='status'][value='{$vo.status ?? '1'}']").prop("checked", true);
        $("[name='table_name']").find("[value='{$vo.table_name ?? ''}']").attr("selected", true);
        $("[name='field_name']").find("[value='{$vo.field_name ?? ''}']").attr("selected", true);

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret){
                ajax_progress(ret);
            }
        });
    })
</script>
{/block}
